package com.homer.android.sdk.action.device.common;

import com.homer.android.sdk.command.uart.EspCommandUartPostStatusInternet;
import com.homer.android.sdk.command.uart.IEspCommandUartPostStatusInternet;
import com.homer.android.sdk.devcie.IEspDevice;
import com.homer.android.sdk.devcie.status.IEspStatusUart;
import com.homer.iot.esptouch.udp.EspDeviceType;

public class EspActionDevicePostStatusInternet implements
		IEspActionDevicePostStatusInternet {

	@Override
	public boolean doActionDevicePostStatusInternet(IEspDevice device,
			String base64String) {
		EspDeviceType deviceType = device.getDeviceType();
		String deviceNumber = device.getDeviceNumber();
		boolean suc = false;
		switch (deviceType) {
		case UART:

			IEspCommandUartPostStatusInternet uartCommand = new EspCommandUartPostStatusInternet();
			suc = uartCommand.doCommandUartPostStatusInternet(deviceNumber,
					base64String);
//			if (suc) {
//				IEspStatusUart uartDevice = (IEspStatusUart) device;
//				uartDevice.setIsOnline(true);
//
//			}
			return suc;

		case NEW:
			break;
		default:
			break;
		}
		throw new IllegalArgumentException();

	}

	// private void doRootRouterCommandInternet(IEspDeviceRoot device,
	// IEspDeviceStatus status)
	// {
	// List<IEspDeviceTreeElement> childList =
	// device.getDeviceTreeElementList();
	// for (IEspDeviceTreeElement element : childList)
	// {
	// if (element.getLevel() == FIRST_CHILD_LEVEL)
	// {
	// IEspDevice child = element.getCurrentDevice();
	// EspBaseApiUtil.submit(new RootStatusRunnable(child, status));
	// }
	// }
	// }
	//
	// private class RootStatusRunnable implements Runnable
	// {
	// private IEspDevice device;
	//
	// private IEspDeviceStatus status;
	//
	// public RootStatusRunnable(IEspDevice device, IEspDeviceStatus status)
	// {
	// this.device = device;
	// this.status = status;
	// }
	//
	// @Override
	// public void run()
	// {
	//
	// if (status instanceof IEspStatusUart)
	// {
	// IEspStatusUart uartStatus = (IEspStatusUart)status;
	// IEspCommandUartPostStatusInternet uartCommand = new
	// EspCommandUartPostStatusInternet();
	// uartCommand.doCommandUartPostStatusInternet(device.getDeviceNumber(),
	// uartStatus);
	// }
	// }
	// }

}
